import Vue from 'vue'
import Vuex from 'vuex'
import { setToken, getToken, removeToken } from '../utils/storage'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    tokens: getToken() || {}
  },
  getters: {},
  mutations: {
    // 登录
    login (state, payload) {
      state.tokens = payload
      setToken(payload)
    },
    // 退出登录
    logout (state) {
      state.tokens = {}
      removeToken()
    }
  },
  actions: {},
  modules: {}
})
